package com.sihai.ehr.model.biz;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.sihai.core.BaseEntity;
import com.sihai.ehr.model.sys.Organization;

/**
 * 薪资框架模型
 * 
 * @author henry
 * 
 */
@Entity
public class SalaryStructure extends BaseEntity<Long> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8073742774308029631L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	/** 组织结构ID */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "organization_id")
	private Organization organization;
	/** 方案名称 */
	private String projectTitle;

	/** 方案计算表达式 %在其中 */
	private String expression;

	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "salaryStructure")
	private Set<SalaryStructureDetail> details = new HashSet<SalaryStructureDetail>();
	
	private int cancel;	//0：正常,1:删除

	@Override
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public String getProjectTitle() {
		return projectTitle;
	}

	public void setProjectTitle(String projectTitle) {
		this.projectTitle = projectTitle;
	}

	public String getExpression() {
		return expression;
	}

	public void setExpression(String expression) {
		this.expression = expression;
	}

	public void setDetails(Set<SalaryStructureDetail> details) {
		this.details = details;
	}

	public Set<SalaryStructureDetail> getDetails() {
		return details;
	}
	
	
	/**
	 * 该方法用于向对象中加对象子集项
	 * 
	 * @param structureDetail
	 */
	public void addDetailItem(SalaryStructureDetail structureDetail) {
		structureDetail.setSalaryStructure(this); // 用关系维护端来维护关系
		this.details.add(structureDetail);
	}
	
	public int getCancel() {
		return cancel;
	}
	
	public void setCancel(int cancel) {
		this.cancel = cancel;
	}
}
